<?PHP
#
# author: Cody Sorgenfrey
# (c)2012 South Hill Calvary Chapel
#


include_once("../mysql/database_info.php");
include_once("common.php");
include_once("../mysql/common.php");

$title = 'Sermon Series';
$meta_key= 'series, topic, topical, sermons, teaching, Bible, God, Jesus, Word, Old Testament, New Testament, scripture';
$meta_desc="A serires of Bible teachings on particular topic given at South Hill Calvary Chapel.";

if (isset($_GET['id']) && isset($_GET['table']) && isset($_GET['title']) ) {
  	$id = $_GET['id'];
  	$table = $_GET['table'];
  	$title = $title.': '.$_GET['title'];
	$title = htmlspecialchars($title, ENT_QUOTES);
	$morehtml= null;
	$morejava= null;
	startPage($title, $meta_key, $meta_desc, $morehtml, $morejava);


  	connect_select_test($table);
  	$query="SELECT * FROM $table WHERE series_id='$id' ORDER BY date ASC";
  	$result=mysql_query($query) or die (mysql_error());
  	$num_rows=mysql_num_rows($result);
  	msermon_table($result,$num_rows,$table);
}
else if (isset($_GET['id']) || isset($_GET['table']) || isset($_GET['title'])) {
  die ("Error:  Must define id, table, and title not just one.");
} else {
	$morehtml= null;
	$morejava= null;
	startPage($title, $meta_key, $meta_desc, $morehtml, $morejava);

	printf("<div class='paragraph'>\n");
	printf("\t<p>Featured below are a list of series taught at South Hill Calvary Chapel to address a particular subject.<br/>Click on any title to see the teachings on each subject.</p>\n");
	printf("</div>\n");
	
	$table = "sermon_series";
	connect_select_test($table);
	$query="SELECT * FROM $table ORDER BY date DESC";
	$result=mysql_query($query) or die (mysql_error());
	$num_rows=mysql_num_rows($result);
	msermon_series_table($result,$num_rows,$table);
}
printf("<br>\n");


endPage();

mysql_close();

?>